
// 测试中循环读取行,直到输入空行

#include <stdio.h>
#include <string.h>
#define SIZE 40
char * delete_space(char *);

int main(void)
{
	/**
	char str []  = "hello world!";
	char * end = delete_space(str);
	
	puts(end);
	**/
	char str[SIZE];
	char * ans = NULL;

	printf("Enter a string (enter to quit): ");
	fgets(str, SIZE, stdin);
	while(*str != '\n')
	{
		ans = delete_space(str);
		printf("Done!\nNow the string is:");
		puts(ans);
		printf("Another? Enter a string(enter to quit.):");
		fgets(str, SIZE, stdin);		
	}	

	return 0;
}

char * delete_space(char * str)
{
	char * temp_str = str;	
	int i = 0;

	while (*temp_str)
	{
		if (*temp_str != ' ') 
			str[i++] = *temp_str;
		temp_str++;
	}
	str[i] = '\0';

	return str;
}
